package com.smartbus.bus.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.smartbus.common.annotation.Log;
import com.smartbus.common.core.controller.BaseController;
import com.smartbus.common.core.domain.AjaxResult;
import com.smartbus.common.enums.BusinessType;
import com.smartbus.bus.domain.AnnouncementTypes;
import com.smartbus.bus.service.IAnnouncementTypesService;
import com.smartbus.common.utils.poi.ExcelUtil;
import com.smartbus.common.core.page.TableDataInfo;

/**
 * 报站类型配置，定义不同的报站场景（即将到站、已到达、换乘提示等）Controller
 * 
 * @author ruoyi
 * @date 2025-09-24
 */
@RestController
@RequestMapping("/bus/types")
public class AnnouncementTypesController extends BaseController
{
    @Autowired
    private IAnnouncementTypesService announcementTypesService;

    /**
     * 查询报站类型配置，定义不同的报站场景（即将到站、已到达、换乘提示等）列表
     */
    @PreAuthorize("@ss.hasPermi('bus:types:list')")
    @GetMapping("/list")
    public TableDataInfo list(AnnouncementTypes announcementTypes)
    {
        startPage();
        List<AnnouncementTypes> list = announcementTypesService.selectAnnouncementTypesList(announcementTypes);
        return getDataTable(list);
    }

    /**
     * 导出报站类型配置，定义不同的报站场景（即将到站、已到达、换乘提示等）列表
     */
    @PreAuthorize("@ss.hasPermi('bus:types:export')")
    @Log(title = "报站类型配置，定义不同的报站场景（即将到站、已到达、换乘提示等）", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AnnouncementTypes announcementTypes)
    {
        List<AnnouncementTypes> list = announcementTypesService.selectAnnouncementTypesList(announcementTypes);
        ExcelUtil<AnnouncementTypes> util = new ExcelUtil<AnnouncementTypes>(AnnouncementTypes.class);
        util.exportExcel(response, list, "报站类型配置，定义不同的报站场景（即将到站、已到达、换乘提示等）数据");
    }

    /**
     * 获取报站类型配置，定义不同的报站场景（即将到站、已到达、换乘提示等）详细信息
     */
    @PreAuthorize("@ss.hasPermi('bus:types:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(announcementTypesService.selectAnnouncementTypesById(id));
    }

    /**
     * 新增报站类型配置，定义不同的报站场景（即将到站、已到达、换乘提示等）
     */
    @PreAuthorize("@ss.hasPermi('bus:types:add')")
    @Log(title = "报站类型配置，定义不同的报站场景（即将到站、已到达、换乘提示等）", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AnnouncementTypes announcementTypes)
    {
        return toAjax(announcementTypesService.insertAnnouncementTypes(announcementTypes));
    }

    /**
     * 修改报站类型配置，定义不同的报站场景（即将到站、已到达、换乘提示等）
     */
    @PreAuthorize("@ss.hasPermi('bus:types:edit')")
    @Log(title = "报站类型配置，定义不同的报站场景（即将到站、已到达、换乘提示等）", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AnnouncementTypes announcementTypes)
    {
        return toAjax(announcementTypesService.updateAnnouncementTypes(announcementTypes));
    }

    /**
     * 删除报站类型配置，定义不同的报站场景（即将到站、已到达、换乘提示等）
     */
    @PreAuthorize("@ss.hasPermi('bus:types:remove')")
    @Log(title = "报站类型配置，定义不同的报站场景（即将到站、已到达、换乘提示等）", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(announcementTypesService.deleteAnnouncementTypesByIds(ids));
    }
}
